# Create your views here.
from django.http import HttpResponse, Http404
from django.shortcuts import render_to_response
from news.models import News, NewsCategory
from django.core.context_processors import request
from news.models import News, NewsCategory

def index(request):
    news = News.objects.filter(category_id=1).order_by('create_date')
    return  render_to_response('news/index.html',{'news_list' : news})

def ditail_new(request,id):
    #return HttpResponse('This is id' +id);
    try:
        new_detail = News.objects.get(pk=id)
    except  News.DoesNotExist:
        raise Http404
    return render_to_response('news/new_detail.html', {'new': new_detail})